import React from 'react';
import { useNavigate } from 'react-router-dom';
import { Menu } from 'antd';
import {
  DashboardFilled,
  MailOutlined,
  SignalFilled,
  LockFilled,
  ChromeFilled,
  CarryOutFilled,
  AppstoreFilled,
  SettingFilled,
} from '@ant-design/icons';
function getItem(label, key, icon, children, type) {
  return {
    key,
    icon,
    children,
    label,
    type,
  };
}
const items = [
  getItem('首页', 'home', <DashboardFilled />),
  getItem('访客记录', 'visitor', <MailOutlined />, [
    getItem('访客列表', 'visitor/visitorlist'),
    getItem('访客添加修改', 'visitor/visitoradd'),
    getItem('负责人操作导入详细', 'visitor/visitorprincipal'),
  ]),
  getItem('部门管理', 'deparment', <SignalFilled />, [
    getItem('部门列表', 'deparment/deparmentlist'),
    getItem('部门添加修改', 'deparment/deparmentadd'),
  ]),
  getItem('管理员', 'administrator', <LockFilled />, [
    getItem('管理员列表', 'administrator/administratorlist'),
    getItem('管理员添加修改', 'administrator/administratoradd'),
  ]),
  getItem('核销人员管理', 'cancel', <ChromeFilled />, [
    getItem('核销人员列表', 'cancel/cancellist'),
    getItem('核销人员添加修改', 'cancel/canceladd'),
    getItem('核销人员日志', 'cancel/cancellog'),
  ]),
  getItem('审核日志', 'audit', <CarryOutFilled />, [
    getItem('审核列表', 'audit/auditlist'),
  ]),
  getItem('校园动态', 'campus', <AppstoreFilled />, [
    getItem('校园动态列表', 'campus/campuslist'),
    getItem('校园动态添加修改', 'campus/campusadd'),
  ]),
  getItem('系统设置', 'system', <SettingFilled />),
];
export default function IndexMenu(props) {
  const navigate = useNavigate();
  const path = sessionStorage.getItem('path')
    ? sessionStorage.getItem('path')
    : 'home';
  const goPath = (key) => {
    props.getPath(key, items);
    sessionStorage.setItem('path', key.key);
    navigate('/index/' + key.key);
  };
  return (
    <Menu
      defaultSelectedKeys={[path]}
      mode="inline"
      theme="dark"
      inlineCollapsed={props.collapsed}
      onSelect={(key) => goPath(key)}
      items={items}
    />
  );
}
